home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 05.zip / BS1 part 5 / PDraw3.0.adf / pdraw_rex.lzh / SpaceObjects.pdrx < prev    next >
Text File  |  1992-06-17  |  3KB  |  152 lines

  1. /*
  2. @N
  3.  
  4. This Genie will reposition all the objects in the current selection. Objects will be spaced out by a user-specified distance. Distance can be set between left, right, top, or bottom edges, object centers, or objects.
  5.  
  6. */
  7. msg = PDSetup.rexx(2,0)
  8. units = getclip(pds_units)
  9. if msg ~= 1 then exit_msg(msg)
  10. cr = '0a'x
  11.  
  12. signal on halt
  13. signal on break_c
  14. signal on break_e
  15. signal on break_d
  16.  
  17. if pdm_NumSelObjs() = 0 then exit_msg("Please select a group of objects first")
  18.  
  19. hspacing = "Left"cr"Right"cr"Centers"cr"_Objects"cr"None"
  20. vspacing = "Top"cr"Bottom"cr"Centers"cr"_Objects"cr"None"
  21.  
  22. hspacing = pdm_SelectFromList("Horizontal Spacing..", 15, 5, 2, hspacing)
  23. if hspacing = '' then exit_msg()
  24.  
  25. vspacing = pdm_SelectFromList("Vertical Spacing..", 15, 5, 2, vspacing)
  26. if vspacing = '' then exit_msg()
  27.  
  28. vdist = 0
  29. hdist = 0
  30.  
  31. if hspacing ~= "None" then
  32. do
  33.     string = hspacing
  34.     if hspacing="Left" | hspacing="Right" then
  35.     do
  36.         string = hspacing" edges"
  37.     end
  38.  
  39.     hdist = pdm_GetForm( "Enter Horizontal Spacing", 8, "Between "string)
  40.     if hdist = '' then exit_msg()
  41.     if hdist < 0 then exit_msg()
  42.  
  43.     if ~datatype(hdist, n) then
  44.         call exit_msg("Invalid Input")
  45.  
  46.     if units = 3 then
  47.         hdist = pdm_ConvertUnits(3, 1, hdist)
  48. end
  49.  
  50. if vspacing ~= "None" then
  51. do
  52.     string = vspacing
  53.     if vspacing="Top" | vspacing="Bottom" then
  54.     do
  55.         string = vspacing" edges"
  56.     end
  57.  
  58.     vdist = pdm_GetForm( "Enter Vertical Spacing", 8, "Between "string)
  59.     if vdist = '' then exit_msg()
  60.     if vdist < 0 then exit_msg()
  61.  
  62.     if ~datatype(vdist, n) then
  63.         call exit_msg("Invalid Input")
  64.  
  65.     if units = 3 then
  66.         vdist = pdm_ConvertUnits(3, 1, vdist)
  67. end
  68.  
  69. /****change to getSelRect*****/
  70. grouprect    = pdm_GetObjPosn(pdm_SelFirstObj())
  71. groupleft    = word(grouprect, 1)
  72. grouptop    = word(grouprect, 2)
  73.  
  74. hspace    = "hpos = hpos + hdist"
  75. vspace    = "vpos = vpos + vdist"
  76. vpos    = grouptop
  77. hpos    = groupleft
  78.  
  79. if vspacing = "Top" then
  80.     vstring = "vpos"
  81. else if vspacing = "Bottom" then
  82.     vstring = "vpos - height"
  83. else if vspacing = "Centers" then
  84.     vstring = "vpos - .5 * height"
  85. else if vspacing = "Objects" then
  86. do
  87.     vstring = "vpos"
  88.     vspace    = "vpos = vpos + height + vdist"
  89. end
  90. else
  91. do
  92.     vstring = "top"
  93.     vspace    = "/**/"
  94. end
  95.  
  96. if hspacing = "Left" then
  97.     hstring = "hpos"
  98. else if hspacing = "Right" then
  99.     hstring = "hpos - width"
  100. else if hspacing = "Centers" then
  101.     hstring = "hpos - .5 * width"
  102. else if hspacing = "Objects" then
  103. do
  104.     hstring = "hpos"
  105.     hspace    = "hpos = hpos + width + hdist"
  106. end
  107. else
  108. do
  109.     hstring = "left"
  110.     hspace    = "/**/"
  111. end
  112.  
  113. obj = pdm_SelFirstObj()
  114.  
  115. do while obj ~= 0
  116.  
  117.     objpos  = pdm_GetObjPosn(obj)
  118.     left    = word(objpos, 1)
  119.     top        = word(objpos, 2)
  120.     objsze    = pdm_GetObjSize(obj)
  121.     width    = word(objsze, 1)
  122.     height    = word(objsze, 2)
  123.  
  124.     interpret "x = "hstring
  125.     interpret "y = "vstring
  126.     call pdm_SetObjPosn(obj, x, y)
  127.     interpret hspace
  128.     interpret vspace
  129.  
  130.     obj = pdm_SelNextObj(obj)
  131.  
  132. end
  133. call exit_msg()
  134. break_d:
  135. break_e:
  136. break_c:
  137. halt:
  138.     call exit_msg("User aborted Genie!")
  139.  
  140. exit_msg: procedure expose units
  141. do
  142.     parse arg message
  143.  
  144.     if message ~= '' then
  145.     call pdm_Inform( 1, message, )
  146.  
  147.     if units = 3 then call pdm_SetUnits(3)
  148.     call pdm_AutoUpdate(1)
  149.     exit
  150.  
  151. end
  152.